package cn.kgc.common.vo;


import cn.kgc.common.constant.ResultConstant;
import lombok.*;

import java.io.Serializable;

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
@SuppressWarnings("serial")
/**
 * @author kgc
 */
public class Result<T> implements Serializable {
    /**
     * 返回的编码
     */
    private int code;
    /**
     * 返回的信息
     */
    private String message;
    /**
     * 返回的数据
     */
    private T data;

    /**
     * 处理成功
     * @return   返回Result对象
     */
    public static Result success() {
        int code = ResultConstant.SUCCESS.getCode();
        String message = ResultConstant.SUCCESS.getMessage();
        return Result.builder().code(code).message(message).build();
    }

    /**
     * 处理成功
     * @return   返回Result对象
     */
    public static Result success(Object data) {
        return Result.builder().code(ResultConstant.SUCCESS.getCode())
                .message(ResultConstant.SUCCESS.getMessage())
                .data(data)
                .build();
    }

}
